<template>
  <div>
    <el-row>
      <el-col :span="24">
        <el-form :inline="true" class="demo-form-inline">
          <el-form-item label="">
            <el-input
              v-model="foodName"
              size="medium"
              placeholder="查询用户名"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              size="small"
              type="success"
              icon="el-icon-search"
              @click="getRecord()"
              >查询</el-button
            >
          </el-form-item>
          <el-form-item label="">
            <el-button size="small" type="warning" icon="el-icon-delete-solid"
              >清空</el-button
            >
          </el-form-item>
        </el-form>
      </el-col>
      <el-col :span="24">
        <el-table
          :data="inToronto"
          border
          v-loading="loadFlag"
          highlight-current-row
          @current-change="handleCurrentChange"
          style="width: 100%"
        >
          <el-table-column prop="id" label="ID" width="50"> </el-table-column>
          <el-table-column prop="clientName" label="客户名称" width="200">
          </el-table-column>
          <el-table-column prop="level" label="客户级别" width="">
          </el-table-column>
          <el-table-column prop="startingTime" label="开始时间" width="">
          </el-table-column>
          <el-table-column prop="endingTime" label="结束时间">
          </el-table-column>
          <el-table-column prop="type" label="项目类型"> </el-table-column>
          <el-table-column prop="responsible" label="责任人"> </el-table-column>
          <el-table-column prop="remarks" label="备注"> </el-table-column>
          <el-table-column prop="serialNumber" label="序列号">
          </el-table-column>
          <el-table-column prop="address5" label="项目总结"> </el-table-column>
          <el-table-column prop="address6" label="结算统计"> </el-table-column>
        </el-table>
        <div class="pagingClass">
          <el-pagination
            :page-sizes="m_page.sizes"
            :page-size="m_page.size"
            :current-page="m_page.number"
            @size-change="m_handleSizeChange"
            @current-change="m_handlePageChange"
            layout="total,sizes,prev, pager, next"
            background
            :total="m_page.totalElements"
          ></el-pagination>
        </div>
        <div class="dialog-footer" style="text-align: center">
          <!-- <el-button @click="closeCalendar">取消</el-button>
          <el-button type="primary" @click="determine()">确 定</el-button> -->
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loadFlag: false, //加载flag
      foodName: "",
      inToronto: [],
      m_page: {
        sizes: [10, 20, 40, 50, 100], //每页最大显示数
        size: 10,
        totalElements: 0,
        totalPages: 3,
        number: 1,
      },
    };
  },
  beforeMount() {
    this.getRecord();
  },
  methods: {
    handleCurrentChange(val) {
      //   console.log(val);
      this.$emit("wtc_serial", val);
    },
    getRecord() {
      this.loadFlag = true;
      this.$axios({
        methods: "GET",
        url: "api/serial/ProjectList",
        headers: {
          Authorization: this.headerObj,
        },
        params: {
          pageSize: this.m_page.size,
          pageIndex: this.m_page.number,
          query: {
            categoryName: this.foodName,
          },
        },
      }).then((res) => {
        ({ data: this.inToronto, count: this.m_page.totalElements } = res.data);
        this.loadFlag = false;
      });
    },
    //页码
    m_handlePageChange(currPage) {
      this.m_page.number = currPage;
      this.getRecord();
    },
    m_handleSizeChange(currSize) {
      this.m_page.size = currSize;
      this.getRecord();
    },
  },
};
</script>

<style scoped>
</style>